package cn.xdd.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class RabbitMqUtils {
    //得到一个连接的 channel
    public static Channel getChannel() throws Exception {
//创建一个连接工厂 
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
//        factory.setHost("115.29.209.196");
        factory.setHost("192.168.78.129");
        factory.setUsername("xdd");
        factory.setPassword("Jiansheyin1");
        //channel 实现了自动 close 接口 自动关闭 不需要显示关闭
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        return channel;
    }
} 
